( function($) {
	$.fn.extend( {
		Scroll : function(opt, callback) {
			//参数初始化
			if (!opt)
				var opt = {};
			var direction = opt.direction;//滚动方向
			var _btnUp = $("#" + opt.up);//向上按钮
			var _btnDown = $("#" + opt.down);//向下按钮
			var _btnLeft = $("#" + opt.left);//向左按钮
			var _btnRight = $("#" + opt.right);//向右按钮
			var autoScroll = opt.autoScroll;
			var timerID;
			var _this = this.eq(0).find("ul:first");
			var lineH = _this.find("li:first").height(), //获取行高
			hight = opt.hight ? parseInt(opt.hight, 10) : parseInt(this.height()/ lineH, 10), //每次滚动的行数，默认为一屏，即父容器高度
			speed = opt.speed ? parseInt(opt.speed, 10) : 500; //卷动速度，数值越大，速度越慢（毫秒）
			timer = opt.timer //?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
			if (hight == 0)
				hight = 1;
			var upHeight = 0 - hight * lineH;
			var lineW = _this.find("li:first").width(), //获取行宽
			width = opt.width ? parseInt(opt.width, 10) : parseInt(this.width()/ lineW, 10), //每次滚动的行数，默认为一屏，即父容器高度
			speed = opt.speed ? parseInt(opt.speed, 10) : 500; //卷动速度，数值越大，速度越慢（毫秒）
			timer = opt.timer //?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
			if (width == 0)
				width = 1;
			var upWidth = 0 - width * lineW;
			if(direction){
				switch(direction){
				case 'up':
					//向上滚动函数
					var scrollUp = function() {
						_btnUp.unbind("click", scrollUp); //取消向上按钮的函数绑定
						_this.animate( {
							marginTop : upHeight
						}, speed, function() {
							for (i = 1; i <= hight; i++) {
								_this.find("li:first").appendTo(_this);
							}
							_this.css( {
								marginTop : 0
							});
							_btnUp.bind("click", scrollUp); //绑定向上按钮的点击事件
							});

					}
					//向下滚动函数
					var scrollDown = function() {
						_btnDown.unbind("click", scrollDown);
						for (i = 1; i <= hight; i++) {
							_this.find("li:last").show().prependTo(_this);
						}
						_this.css( {
							marginTop : upHeight
						});
						_this.animate( {
							marginTop : 0
						}, speed, function() {
							_btnDown.bind("click", scrollDown);
						});
					}
					if(autoScroll == true){
						//自动播放
						var autoPlay = function() {
							if (timer)
								timerID = window.setInterval(scrollUp, timer);
						};
						var autoStop = function() {
							if (timer)
								window.clearInterval(timerID);
						};
						//鼠标事件绑定
						_this.hover(autoStop, autoPlay).mouseout();
					}
					_btnUp.css("cursor", "pointer").click(scrollUp).hover(autoStop,autoPlay);//向上向下鼠标事件绑定
					_btnDown.css("cursor", "pointer").click(scrollDown).hover(autoStop, autoPlay);
					break;
				case 'left':
					//向左滚动函数
					var scrollLeft = function() {
						_btnLeft.unbind("click", scrollLeft); //取消向上按钮的函数绑定
						_this.animate( {
							marginLeft : upWidth
						}, speed, function() {
							for (i = 1; i <= width; i++) {
								_this.find("li:first").appendTo(_this);
							}
							_this.css( {
								marginLeft : 0
							});
							_btnLeft.bind("click", scrollLeft); //绑定向上按钮的点击事件
							});

					}
					//向右滚动函数
					var scrollRight = function() {
						_btnRight.unbind("click", scrollRight);
						for (i = 1; i <= width; i++) {
							_this.find("li:last").show().prependTo(_this);
						}
						_this.css( {
							marginLeft : upWidth
						});
						_this.animate( {
							marginLeft : 0
						}, speed, function() {
							_btnRight.bind("click", scrollRight);
						});
					}
					if(autoScroll == true){
						//自动播放
						var autoPlay = function() {
							if (timer)
								timerID = window.setInterval(scrollLeft, timer);
						};
						var autoStop = function() {
							if (timer)
								window.clearInterval(timerID);
						};
						//鼠标事件绑定
						_this.hover(autoStop, autoPlay).mouseout();						
					}
					_btnLeft.css("cursor", "pointer").click(scrollLeft).hover(autoStop,autoPlay);//向上向下鼠标事件绑定
					_btnRight.css("cursor", "pointer").click(scrollRight).hover(autoStop, autoPlay);
					break;
				}
			}
		}
	})
})(jQuery);


/*-----------------------------------------------------------------------------------------/
 * JQuery PlugIn - Slide Show(or, Switch Tab)
 * JQuery滑动切换插件 ver 1.2.0
 *
 * defaultIndex 	- 默认选中的标签索引，从0开始
 * titOnClassName	- 标签选中时的样式
 * titCell			- 自定义标题标签，支持选择符
 * mainCell			- 自定义标题标签，支持选择符
 * delayTime		- 延迟触发时间. 当这个时间小于切换动画效果时间时, 动画将被禁用
 * interTime		- 自动切换时间. 当这个时间大于0时, 标签将定时自动切换
 * trigger			- 滑动触发方式. 默认为click, 可选择mouseover
 * effect			- 切换动画. 默认不使用动画. 目前仅提供fade(淡出), slide(向下展开)两种
 * omitLinks		- 是否忽略带链接标签，默认为否
 * debug			- 调试模式. 默认关闭
/*----------------------------------------------------------------------------------------*/
// 浏览器判断
var isIE6 = (navigator.userAgent.toLowerCase().indexOf("msie 6") != -1);
var isIE = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);


jQuery.fn.switchTab = function(settings) {
	settings = jQuery.extend({//可配置参数
		defaultIndex: 0,
		titOnClassName: "on",
		titCell: "dt span",
		mainCell: "dd",
		delayTime: 250,
		interTime: 0,
		trigger: "click",
		effect: "",
		omitLinks: false,
		debug: ""
	},
	settings,
	{//插件信息
		version: 120
	});

	this.each(function() {
		var st;
		var curTagIndex = -1;
		var obj = jQuery(this);
		if(settings.omitLinks && settings.titCell.substr(settings.titCell.length-1, 1)=="a"){
			settings.titCell = settings.titCell + "[href^='#']";
		}
		var oTit = obj.find(settings.titCell);
		var oMain = obj.find(settings.mainCell);
		var cellCount = oTit.length;//可切换个数
		var ShowSTCon = function (oi){
			if(oi != curTagIndex){
				if(curTagIndex<0)obj.find(settings.titCell+"."+settings.titOnClassName).removeClass(settings.titOnClassName);
				else oTit.eq(curTagIndex).removeClass(settings.titOnClassName);
				oMain.hide();
				obj.find(settings.titCell + ":eq(" + oi + ")").addClass(settings.titOnClassName);
				if(settings.delayTime <250 && settings.effect != "")settings.effect = "";
				if(settings.effect == "fade"){
					obj.find(settings.mainCell + ":eq(" + oi + ")").fadeIn({queue: false, duration: 250});
				}else if(settings.effect == "slide"){
					obj.find(settings.mainCell + ":eq(" + oi + ")").slideDown({queue: false, duration: 250});
				}else{
					obj.find(settings.mainCell + ":eq(" + oi + ")").show();
				}
				curTagIndex = oi;
			}
		};
		
		var ShowNext = function (){
			oTit.eq(curTagIndex).removeClass(settings.titOnClassName);
			oMain.hide();
			if(++curTagIndex >= cellCount)curTagIndex = 0;
			oTit.eq(curTagIndex).addClass(settings.titOnClassName);
			oMain.eq(curTagIndex).show();
			//ShowSTCon(curTagIndex);
		};
		
		//根据defaultIndex初始化
		ShowSTCon(settings.defaultIndex);

		//定时切换
		if(settings.interTime > 0){
			var sInterval = setInterval(function(){
				ShowNext();
			}, settings.interTime);
		}

		//处理交互事件
		oTit.each(function(i, ele){
			if(settings.trigger=="click"){
				jQuery(ele).click(function(){
					ShowSTCon(i);
					return false;//若有链接而选择了click模式, 链接不起作用
				});
			}else if(settings.delayTime > 0){
				jQuery(ele).hover(function(){
					st = setTimeout(function(){//延时触发
						ShowSTCon(i);
						st = null;
					}, settings.delayTime);
				},function(){
					if(st!=null)clearTimeout(st);
				});
			}else{
				jQuery(ele).mouseover(function(){
					ShowSTCon(i);
				});
			}
		});
	});
	if(settings.debug!="")alert(settings[settings.debug]);
	return this;
};



//垂直向上滚动
//wrapper, 容器选择符
//sItem, 滚动元素选择符
jQuery.fn.scrollUp = function(settings) {
	settings = jQuery.extend({
		delayTime: 4000,
		sItem: 'li'
	}, settings);

	var obj = jQuery(this);
	this.each(function() {
		var stepScroll = function(){
			var curItem = obj.find(settings.sItem + ":first");
			curItem.animate({
				marginTop: "-" + curItem.height()
			},
			300,
			"",
			function(){
				curItem.appendTo(obj);
				curItem.css("margin-top", "0px");
			});
		};
		setInterval(stepScroll, settings.delayTime);
	});
	return this;
};

//内容无缝滚动
function Marquee(marqueeBox, delaytime, direction, itemCell){
	if(delaytime == undefined)delaytime = 50;
	if(direction == undefined)direction = "up";
	if(itemCell == undefined)itemCell = "ul";
	var oMarquee = jQuery(marqueeBox);
	var oMarqueeCon = oMarquee.find(itemCell);
	var oMarqueeCopy = oMarqueeCon.clone(true).insertAfter(oMarqueeCon);

	var ScrollUp = function(){
		if(oMarqueeCopy[0].offsetHeight-oMarquee[0].scrollTop<=0){
			oMarquee[0].scrollTop = 0;
		}else{
			oMarquee[0].scrollTop++;
		}
	}
	
	var ScrollLeft = function(){
		if(oMarqueeCopy[0].offsetWidth-oMarquee[0].scrollLeft<=0){
			oMarquee[0].scrollLeft = 0;
		}else{
			oMarquee[0].scrollLeft++;
		}
	}
	
	switch(direction){
		case "left":
			var oScroll=setInterval(ScrollLeft, delaytime);
			oMarquee.hover(function(){
				clearInterval(oScroll);
			}, function(){
				oScroll=setInterval(ScrollLeft, delaytime);
			});
			break;
		case "up":
		default:
			var oScroll = setInterval(ScrollUp, delaytime);
			oMarquee.hover(function(){
				clearInterval(oScroll);
			}, function(){
				oScroll=setInterval(ScrollUp, delaytime);
			});
	}
}

//列高度统一
function HeightFix(column, column2, offset){
	var oCol = jQuery(column);
	var oCol2 = jQuery(column2);
	if(offset == undefined)offset = 0;
	if(oCol.height() > oCol2.height()){
		oCol2.height(oCol.height() - offset);
	}else{
		oCol.height(oCol2.height() - offset);
	}
}

//获得日期
function RunGLNL(obj){
	var today = new Date();
	var d = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
	var DDDD = (today.getFullYear()<100 ? today.getFullYear()+1900:today.getFullYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日";
	DDDD = DDDD + " " + d[today.getDay()];
	jQuery(obj).text(DDDD);
}


// hover变色
function hover(obj, className){
    jQuery(obj).hover(function(){
        jQuery(this).addClass(className);
    },function(){
        jQuery(this).removeClass(className);
    });
}


//横向滚动
function bizScroll(container, itemCell, btLeft, btRight, interTime){
    if(interTime == undefined)interTime = 0;//间隔时间
	var obj = jQuery(container);
	var defaultDirection = "right";

	//点击图片弹出
	jQuery(itemCell, obj).click(function(){
		jQuery("blockquote", this).slideToggle();
		//return false;
	});
	
	//隐藏已弹出层
	var hideBlock = function(){
		jQuery("blockquote:visible", obj).slideUp();
	};
	
	//点击按钮滚动
	var goRight = function(){
		hideBlock();
		var curA = jQuery((itemCell + ":first"), obj);
		curA.css("margin-left", "10px")
			.animate({marginLeft: "-" + curA.width() + "px"}, 500,
				function(){
					curA.appendTo(obj);
					curA.css("margin-left", "10px");
				});
	}
	var goLeft = function(){
		hideBlock();
		var curA = jQuery((itemCell + ":last"), obj);
		curA.prependTo(obj);
		curA.css("margin-left", "-" + curA.width() + "px")
			.animate({marginLeft: "10px"}, 500);
	}
	jQuery(btRight).click(goRight);
	jQuery(btLeft).click(goLeft);
	
	//按钮悬停样式
	jQuery(btLeft).hover(function(){
		jQuery(this).addClass("shover");
	},function(){
		jQuery(this).removeClass("shover");
	});
	jQuery(btRight).hover(function(){
		jQuery(this).addClass("shover");
	},function(){
		jQuery(this).removeClass("shover");
	});

	//定时切换
	if(interTime > 0){
		var ShowNext = goLeft;
		if(defaultDirection=="right")ShowNext = goRight;
		
		var sInterval = setInterval(function(){
			ShowNext();
		}, interTime);
	}
}




//DIV下拉选项
jQuery.fn.selectList = function(settings) {
    settings = jQuery.extend({//可配置参数
        titCell: "dt",
        selectCell: "dd",
        itemCell: "li",
        itemOnClass: "on",
        delayTime: 1000
    },
	settings);

    this.each(function() {
		var st;
        var obj = jQuery(this);
		obj.data("sValue", "全部");
		
		obj.click(function(){
			jQuery(settings.selectCell, obj).toggle();
		});
		
		obj.hover(function(){
			if(st!=null)clearTimeout(st);
		},function(){
			st = setTimeout(function(){
				jQuery(settings.selectCell, obj).hide();
				st = null;
			}, settings.delayTime);
		});
	
		jQuery(settings.itemCell, obj).hover(function(){
			jQuery(this).addClass(settings.itemOnClass);
		},function(){
			jQuery(this).removeClass(settings.itemOnClass);
		});
		
		jQuery(settings.itemCell, obj).click(function(){
			var sTemp = jQuery(this).text();
			obj.data("sValue", sTemp);
			jQuery(settings.titCell, obj).text(sTemp);
		});
    });
    return this;
};

function selectList(container){
	var obj = jQuery(container);
}